/**
 * 
 */
package net.cmath.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @author Administrator
 * 
 */
public class TestAop {

	public void doAfter(JoinPoint jp) {
		System.out.println("log Ending method: "
				+ jp.getTarget().getClass().getName() + "."
				+ jp.getSignature().getName());
	}

	public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
		long time = System.currentTimeMillis();
		Object retVal = pjp.proceed();
		time = System.currentTimeMillis() - time;
		System.out.println("process time: " + time + " ms");
		return retVal;
	}

	public void doBefore(JoinPoint jp) {
		System.out.println("log Begining method: "
				+ jp.getTarget().getClass().getName() + "."
				+ jp.getSignature().getName());
	}

	public void doThrowing(JoinPoint jp, Throwable ex) {
		//System.out.println("method " + jp.getTarget().getClass().getName()
		//		+ "." + jp.getSignature().getName() + " throw exception");
		//ex.printStackTrace();
		System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:" + ex.getMessage());
	}
}
